export default {
  namespaced: true, // 开启命名空间
  state: {
    // 存放状态
    userInfo:
      localStorage.getItem("userInfo") !== ""
        ? JSON.parse(localStorage.getItem("userInfo"))
        : null,
  },
  getters: {
    // 计算属性
  },
  mutations: {
    // 定义修改状态的方法
    setUserInfo(state, value) {
      if (value) {
        state.userInfo = value;
        localStorage.setItem("userInfo", JSON.stringify(value));
      }
    },
  },
  actions: {
    // 定义异步方法
    updateUserInfo({ commit }) {
      commit("setUserInfo", {
        name: "萧宇笑",
        motto: "只是热爱！",
        avatar: require("@/assets/images/img_touxiang.png"),
        contactList: [
          {
            id: 1,
            key: "QQ",
            icon: require("@/assets/icons/icon_qq_36@3x.png"),
            code: require("@/assets/images/img_qq_code.png"),
            title: "QQ",
            content: "211171767",
            path: "/",
          },
          {
            id: 2,
            key: "WeChat",
            icon: require("@/assets/icons/icon_wechat_36@3x.png"),
            code: require("@/assets/images/img_wechat_code.png"),
            title: "微信",
            content: "211171767",
            path: "/",
          },
          {
            id: 3,
            key: "163com",
            icon: require("@/assets/icons/icon_email_36@3x.png"),
            code: "",
            title: "邮箱",
            content: "xiaofan99818@163.com",
            path: "/",
          },
        ],
      });
    },
  },
};
